package com.edfu.core.testmgt.persistence.api;

import java.util.List;
import java.util.Set;

import com.edfu.core.commons.persistence.entity.CategoryEntity;
import com.edfu.core.identitymgt.persistence.entity.UserEntity;
import com.edfu.core.testmgt.persistence.entity.AnswersEntity;
import com.edfu.core.testmgt.persistence.entity.FormatTypeEntity;
import com.edfu.core.testmgt.persistence.entity.ImageEntity;
import com.edfu.core.testmgt.persistence.entity.OptionEntity;
import com.edfu.core.testmgt.persistence.entity.QuestionEntity;
import com.edfu.core.testmgt.persistence.entity.QuestionTypeEntity;
import com.edfu.core.testmgt.persistence.entity.TestBundleEntity;
import com.edfu.core.testmgt.persistence.entity.TestEntity;
import com.edfu.core.testmgt.persistence.entity.TestTypeEntity;
import com.edfu.core.testmgt.persistence.entity.UserTestAnswersEntity;
import com.edfu.core.testmgt.persistence.entity.UserTestSubscriptionEntity;

public interface ITestMgtPersistence {
	
	public TestEntity createTest(TestEntity test);
	public TestEntity updateTest(TestEntity test);
	public void removeTest(TestEntity test);
	public TestEntity getTest(long testId);
	public TestEntity getTest(String testCode);
	public boolean isTestUnique(String testCode);
	
	public TestBundleEntity createTestBundle(TestBundleEntity testBundle);
	public TestBundleEntity updateTestBundle(TestBundleEntity testBundle);
	public void removeTestBundle(TestBundleEntity testBundle);
	public TestBundleEntity getTestBundle(long testBundleId);
	public TestBundleEntity getTestBundle(String testBundleCode);
	public List<TestEntity> getTests(TestBundleEntity testBundle);
	public boolean isTestBundleUnique(String testBundleCode);
	
	public TestTypeEntity createTestType(String testTypeName, String testTypeDesc);
	public TestTypeEntity updateTestType(TestTypeEntity testType);
	public void removeTestType(TestTypeEntity testType);
	public List<TestTypeEntity> getTestTypes();
	public TestTypeEntity getTestType(long testTypeId);
	public TestTypeEntity getTestType(String testTypeName);
	public boolean isTestTypeUnique(String testTypeName);
	
	public QuestionEntity addQuestion(TestEntity test, QuestionEntity question);
	public boolean isQuestionUnique(String questionCode);
	public QuestionEntity updateQuestion(QuestionEntity question);
//	public QuestionEntity addOrUpdateQuestion(TestEntity test, QuestionEntity question);
	public void removeQuestion(QuestionEntity question);
	public QuestionEntity getQuestion(long id);
	public QuestionEntity getQuestion(String questionCode);
//	public Set<QuestionEntity> getQuestions(TestEntity test);
//	public Set<QuestionEntity> getQuestionsWithAnswers(TestEntity test);
	public Set<OptionEntity> getAnswers(QuestionEntity question);
	
	public QuestionTypeEntity createQuestionType(String questionTypeName, String questionTypeDesc);
	public QuestionTypeEntity updateQuestionType(QuestionTypeEntity questionType);
	public void removeQuestionType(QuestionTypeEntity questionType);
	public List<QuestionTypeEntity> getQuestionTypes();
	public QuestionTypeEntity getQuestionType(long questionTypeId);
	public QuestionTypeEntity getQuestionType(String questionTypeName);
	public boolean isQuestionTypeUnique(String questionTypeName);
	
	public FormatTypeEntity createFormatType(String formatType);
	public FormatTypeEntity updateFormatType(FormatTypeEntity formatType);
	public void removeFormatType(FormatTypeEntity formatType);
	public List<FormatTypeEntity> getFormatTypes();
	public FormatTypeEntity getFormatType(long formatTypeId);
	public FormatTypeEntity getFormatType(String formatTypeName);
	public boolean isFormatTypeUnique(String formatTypeName);
	
	public OptionEntity getOption(long optionId);
	public OptionEntity addOption(OptionEntity optEnt);
	public OptionEntity updateOption(OptionEntity optEnt);
	public AnswersEntity addAnswer(AnswersEntity ansEnt);
	
	public void subscribeTest(UserTestSubscriptionEntity userTestSubscription);
	public void unsubscribeTest(UserTestSubscriptionEntity userTestSubscription);
	public UserTestSubscriptionEntity addOrUpdateUserTestDetails(UserTestSubscriptionEntity userTest);	
//	public UserTestSubscriptionEntity getUserTestDetails(UserTestSubscriptionEntity userTest);
//	public UserTestSubscriptionEntity getUserTestDetailsWithAnswers(UserTestSubscriptionEntity userTest);
	public void submitUserTestAnswers(UserTestAnswersEntity userTestAnswers);
	public UserTestSubscriptionEntity getUserTestSubscriptionEntity(UserEntity ue, TestEntity te, long testDate);
	
	public ImageEntity addImage(ImageEntity imageEntity);
	public ImageEntity updateImage(ImageEntity imageEntity);
	public void deleteImage(ImageEntity imageEntity);
	public List<ImageEntity> getImages(QuestionEntity questionEntity);
	public ImageEntity getImage(TestEntity testEntity, String fileName);
	public ImageEntity getImage(QuestionEntity questionEntity, OptionEntity optionEntity, String fileName);
	
	public List<TestEntity> getTestDetails();
	public List<TestEntity> getSubscribedTests(UserEntity userEntity);
	
	public List<UserTestAnswersEntity> getUserTestAnswers(TestEntity te, UserEntity ue, long testDate);
	public UserTestSubscriptionEntity updateUserTestSubscription(UserTestSubscriptionEntity userTestSubscription);
	
	public TestEntity associateTestToCategory(TestEntity te);
	public List<TestEntity> getAssociatedTests(CategoryEntity ce);
		
	
}
